using System.Linq;

namespace Pdf2epub.Model
{
    public class HtmlReplacementCollection : BaseCollection<HtmlReplacement>
    {
        public HtmlReplacement this[string styleName]
        {
            get { return this.FirstOrDefault(replacement => replacement.StyleName == styleName); }
        }

        public new void Add(HtmlReplacement htmlReplacement)
        {
            if (!Contains(htmlReplacement))
            {
                base.Add(htmlReplacement);
            }
        }

        public bool Contains(string styleName)
        {
            return this.Any(replacement => replacement.StyleName == styleName);
        }
    }
}